﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class PlayerAnimationController : MonoBehaviour {
	
	[SerializeField]
	private Animator mAnimator;
	private string mCurrentDirection = "";
	private Dictionary<string,Dictionary<string,string>>mAnimationNameList = new Dictionary<string, Dictionary<string, string>>();

    public string AnimationDirection
    {
        get { return mCurrentDirection; }
    }

	// Use this for initialization
	void Start () {

		Dictionary<string,string> TempDic = new Dictionary<string, string>();
		TempDic.Add(AnimationConst.ANIMATION_WALK,"WestWalk");
		TempDic.Add(AnimationConst.ANIMATION_STAY,"WestStay");
		TempDic.Add(AnimationConst.ANIMATION_ATTACK,"WestAttack");
        TempDic.Add("WestHit", "WestHit");
		mAnimationNameList.Add(AnimationConst.WEST,TempDic);

		TempDic = new Dictionary<string, string>();
		TempDic.Add(AnimationConst.ANIMATION_WALK,"EastWalk");
		TempDic.Add(AnimationConst.ANIMATION_STAY,"EastStay");
		TempDic.Add(AnimationConst.ANIMATION_ATTACK,"EastAttack");
		mAnimationNameList.Add(AnimationConst.EAST,TempDic);

		TempDic = new Dictionary<string, string>();
		TempDic.Add(AnimationConst.ANIMATION_WALK,"SouthWalk");
		TempDic.Add(AnimationConst.ANIMATION_STAY,"SouthStay");
		TempDic.Add(AnimationConst.ANIMATION_ATTACK,"SouthAttack");
		mAnimationNameList.Add(AnimationConst.SOUTH,TempDic);

		TempDic = new Dictionary<string, string>();
		TempDic.Add(AnimationConst.ANIMATION_WALK,"NorthWalk");
		TempDic.Add(AnimationConst.ANIMATION_STAY,"NorthStay");
		TempDic.Add(AnimationConst.ANIMATION_ATTACK,"NorthAttack");
		mAnimationNameList.Add(AnimationConst.NORTH,TempDic);
	}

	public void PlayAnimation(string AnimationType, string AnimationDirection = null) {

		if(AnimationDirection != null) {
			mCurrentDirection = AnimationDirection;
		}

		string AnimationName = mAnimationNameList[mCurrentDirection][AnimationType];
		mAnimator.Play(AnimationName);
	}
}
